Fix `--message-format JSON` when rustc emits non-JSON warnings
authorfmdkdd <fmdkdd@gmail.com>
Thu, 15 Dec 2016 23:05:58 +0000 (00:05 +0100)
committerfmdkdd <fmdkdd@gmail.com>
Thu, 15 Dec 2016 23:05:58 +0000 (00:05 +0100)
commit853db7431ad63fbf0fa58879dd179876d25e0997
tree212aff6fe63ee3135648be3229d7d522911b3419
parent65063c5c828ff59812bcc00c965a1141966fadc7
Fix `--message-format JSON` when rustc emits non-JSON warnings

The `--message-format JSON` flag parses all the stderr output of rustc to JSON,
but rustc can emit non-JSON lines to stderr (e.g., for warning about the
unstable `-Z` flag on the stable channel), causing cargo to fail reporting
compilation errors when using `--message-format JSON`.

This commit adds a check to look for lines beginning with `{` to only parse
these lines as JSON.  Other lines from rustc are forwarded to the stderr of
cargo.

Fixes #3390.
src/cargo/ops/cargo_rustc/mod.rs